﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:SlaktDataReader">

    <local:SubLocationConverter x:Key="SubLocationConverter1" />
    <local:LocationBooksConverter x:Key="LocationBooksConverter1" />

    <DataTemplate x:Key="DeathBookTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="200" />
                <ColumnDefinition Width="200" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Grid.Column="0" Grid.RowSpan="2" Text="{Binding Path=RowID}" Margin="20,0,0,0" />

            <TextBlock Grid.Column="1" Text="{Binding Path=DeadDate}" />

            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=BurialDate}" />
            <TextBlock Grid.Column="2" >
                <Run Text="{Binding Path=Title}" />
                <Run Text="{Binding Path=FirstName}" FontWeight="Bold"/> 
                <Run Text="{Binding Path=SurName}" FontWeight="Bold"/>
            </TextBlock>

            <TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding Path=DeadReason}" FontStyle="Italic" />
            <TextBlock Grid.Column="3" Grid.Row="0" Text="{Binding Path=DeadAge}" />
            <TextBlock Grid.Column="3" Grid.Row="1" Text="{Binding Path=BirthDate}" />
            <TextBlock Grid.Column="4" Text="{Binding Path=Address}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="BirthBookTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="200" />
                <ColumnDefinition Width="200" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Grid.Column="0" Grid.RowSpan="2" Text="{Binding Path=RowID}" Margin="20,0,0,0" />

            <TextBlock Grid.Column="1" Text="{Binding Path=BirthDate}" />

            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=ChristeningDate}" />
            <TextBlock Grid.Column="2" >
                <Run Text="{Binding Path=FirstName}" FontWeight="Bold"/> 
                <Run Text="{Binding Path=SurName}" FontWeight="Bold"/>
            </TextBlock>

            <TextBlock Grid.Column="3" Grid.Row="0">
                <Run Text="{Binding Path=FatherTitle}" />
                <Run Text="{Binding Path=FatherFirstName}" FontWeight="Bold" />
                <Run Text="{Binding Path=FatherSurName}" FontWeight="Bold"/>
            </TextBlock>
            <TextBlock Grid.Column="3" Grid.Row="1" >
                <Run Text="{Binding Path=MotherTitle}" />
                <Run Text="{Binding Path=MotherFirstName}" FontWeight="Bold" />
                <Run Text="{Binding Path=MotherSurName}" FontWeight="Bold"/>
            </TextBlock>
            <TextBlock Grid.Column="4" Text="{Binding Path=Address}" />
        </Grid>
    </DataTemplate>

    <!-- Location columns -->
    <DataTemplate DataType="{x:Type GridViewColumnHeader}" x:Key="LocationColumnH" >

    </DataTemplate>
    
    <!--<Style x:Key="LocationColumnH" TargetType="{x:Type GridViewColumnHeader}">

    </Style>-->

    <!--<DataTemplate ></DataTemplate>-->

    <DataTemplate x:Key="BooksInArea">
        <Border Name="Border" CornerRadius="5" Background="{DynamicResource Light3_33}" Padding="5" Margin="5,0">
            <TextBlock Name="TextBlock" Text="{Binding Path=FriendlyName}" Foreground="White" Margin="10,0" />
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=BookType}" Value="Dead">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource BookColor1}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="Born">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource BookColor2}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="Marriages">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource BookColor3}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="HouseCall">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource BookColor4}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="MoveIn">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource BookColor5}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="MoveOut">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource BookColor6}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="Juridical">
                <Setter TargetName="Border" Property="Background" Value="Gray" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="BoU">
                <Setter TargetName="Border" Property="Background" Value="DarkGray" />
                <Setter TargetName="TextBlock" Property="Foreground" Value="Black" />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="LocationCodeData">
        <TextBlock FontSize="18" Grid.Column="0" Height="30" Text="{Binding Path=LocationCode}" HorizontalAlignment="Center"
                           Foreground="{StaticResource Light1}" FontWeight="Light" 
                           VerticalAlignment="Center"/>
    </DataTemplate>

    <DataTemplate x:Key="LocationNameData">
        <TextBlock FontSize="18" Height="30" Foreground="White" Text="{Binding Path=LocationName}" VerticalAlignment="Center" />
    </DataTemplate>
    
    <DataTemplate x:Key="LocationTimeData">
        <TextBlock Grid.Column="2" Grid.Row="0" FontSize="14" Foreground="Gray" VerticalAlignment="Center">
                    <Run Text="{Binding Path=FirstDate}" /> - <Run Text="{Binding Path=LastDate}" />
        </TextBlock>
    </DataTemplate>
    
    <DataTemplate x:Key="LocationSubAreaData">
        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="0,0,40,0" Grid.Column="3">
            <TextBlock Text="{Binding Converter={StaticResource SubLocationConverter1}}"
                           Foreground="DarkGray" HorizontalAlignment="Right" FontSize="14"  
                           VerticalAlignment="Center" Name="txSubLocationCount"/>
            <TextBlock Margin="5,0,0,0" Text="Böcker" x:Name="txPostFix" FontSize="14" Visibility="Visible" 
                               VerticalAlignment="Center" Foreground="Gray"/>
        </StackPanel>

        <DataTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <!--<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource SelectionColor}" />-->
            </Trigger>
            <DataTrigger Binding="{Binding ElementName=txSubLocationCount, Path=Text}" Value="0">
                <Setter TargetName="txSubLocationCount" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="txPostFix" Property="Visibility" Value="Collapsed" />
            </DataTrigger>

            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=Level}" Value="1" />

                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter TargetName="txPostFix" Property="Text" Value="" />
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>

            <MultiDataTrigger >
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=txSubLocationCount, Path=Text}" Value="1" />
                    <Condition Binding="{Binding Path=Level}" Value="2" />
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter TargetName="txPostFix" Property="Text" Value="Bok" />
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>

            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=Level}" Value="2" />
                    <!--<Condition Binding="{Binding ElementName=txSubLocationCount, Path=Text}" Value="0" />-->
                </MultiDataTrigger.Conditions>
                <Setter TargetName="txSubLocationCount" Property="Text" Value="{Binding Converter={StaticResource LocationBooksConverter1}}" />
                <!--<Setter TargetName="txPostFix" Property="Visibility" Value="Visible" />-->
            </MultiDataTrigger>

        </DataTemplate.Triggers>

    </DataTemplate>
    
    <DataTemplate x:Key="LocationDataTemplate">
        <Border Name="Border" BorderThickness="2" >
            <Grid >
                <Grid.RowDefinitions>
                    <RowDefinition Height="35"/>
                    <RowDefinition Height="1" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80" />
                    <ColumnDefinition Width="350" />
                    <ColumnDefinition BindingGroup="lGroup" />
                    <ColumnDefinition BindingGroup="rGroup" />
                </Grid.ColumnDefinitions>

                <TextBlock FontSize="18" Grid.Column="0" Text="{Binding Path=LocationCode}" HorizontalAlignment="Center"
                           Foreground="{StaticResource Light1}" FontWeight="Light" FontFamily="/Fonts/OpenSans-Regular.ttf#Open Sans"
                           VerticalAlignment="Center"/>

                <TextBlock FontSize="18" Grid.Column="1" Foreground="White" Text="{Binding Path=LocationName}" VerticalAlignment="Center" FontFamily="/Fonts/OpenSans-Regular.ttf#Open Sans" />
                <TextBlock Grid.Column="2" Grid.Row="0" FontSize="14" Foreground="Gray" VerticalAlignment="Center" FontFamily="/Fonts/OpenSans-Regular.ttf#Open Sans">
                    <Run Text="{Binding Path=FirstDate}" /> - <Run Text="{Binding Path=LastDate}" />
                </TextBlock>

                <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="0,0,40,0" Grid.Column="3">
                    <TextBlock Text="{Binding Converter={StaticResource SubLocationConverter1}}"
                           Foreground="DarkGray" HorizontalAlignment="Right" FontSize="14"  FontFamily="/Fonts/OpenSans-Regular.ttf#Open Sans"
                           VerticalAlignment="Center" Name="txSubLocationCount"/>
                    <TextBlock Margin="5,0,0,0" Text="Böcker" x:Name="txPostFix" FontSize="14" Visibility="Visible" FontFamily="/Fonts/OpenSans-Regular.ttf#Open Sans"
                               VerticalAlignment="Center" Foreground="Gray"/>
                </StackPanel>
                <!--<TextBlock Text="under" Foreground="DarkGray" HorizontalAlignment="Right" Grid.Column="3" Grid.Row="1"/>-->

                <Grid VerticalAlignment="Bottom" Grid.Row="1" Grid.ColumnSpan="4" Background="{DynamicResource Light3_33}" />
            </Grid>
        </Border>
        <DataTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <!--<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource SelectionColor}" />-->
            </Trigger>
            <DataTrigger Binding="{Binding ElementName=txSubLocationCount, Path=Text}" Value="0">
                <Setter TargetName="txSubLocationCount" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="txPostFix" Property="Visibility" Value="Collapsed" />
            </DataTrigger>

            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=Level}" Value="1" />

                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter TargetName="txPostFix" Property="Text" Value="" />
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>

            <MultiDataTrigger >
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=txSubLocationCount, Path=Text}" Value="1" />
                    <Condition Binding="{Binding Path=Level}" Value="2" />
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter TargetName="txPostFix" Property="Text" Value="Bok" />
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>

            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=Level}" Value="2" />
                    <!--<Condition Binding="{Binding ElementName=txSubLocationCount, Path=Text}" Value="0" />-->
                </MultiDataTrigger.Conditions>
                <Setter TargetName="txSubLocationCount" Property="Text" Value="{Binding Converter={StaticResource LocationBooksConverter1}}" />
                <!--<Setter TargetName="txPostFix" Property="Visibility" Value="Visible" />-->
            </MultiDataTrigger>

        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="BooksDataTemplate">
        <Grid Height="36">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="90"/>
                <ColumnDefinition Width="300" SharedSizeGroup="grpFriendlyName" />
                <ColumnDefinition Width="100" SharedSizeGroup="grpPeriod" />
                <ColumnDefinition Width="250" SharedSizeGroup="grpAuthor" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="1" />
            </Grid.RowDefinitions>

            <Ellipse x:Name="BookCircle" Width="27" Height="27" Fill="White" />
            <TextBlock x:Name="BookTypeL" Text="g" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Garamond"
                       FontSize="14" FontWeight="Bold"/>

            <TextBlock Text="{Binding Path=FriendlyName}" Foreground="White" Grid.Column="1" FontWeight="Light" HorizontalAlignment="Stretch" 
                       VerticalAlignment="Center" FontSize="18" FontFamily="/Fonts/OpenSans-Regular.ttf#Open Sans"/>

            <TextBlock Text="{Binding Path=Period}" Foreground="LightGray" Grid.Column="2" FontWeight="Light" 
                       FontFamily="/Fonts/OpenSans-Regular.ttf#Open Sans"
                       VerticalAlignment="Center" HorizontalAlignment="Stretch" TextTrimming="WordEllipsis" FontSize="14" />
            <TextBlock Text="{Binding Path=Author}" Foreground="Gray" Grid.Column="3" FontWeight="Light" 
                       FontFamily="/Fonts/OpenSans-Regular.ttf#Open Sans"
                       VerticalAlignment="Center" HorizontalAlignment="Stretch" TextTrimming="WordEllipsis" FontSize="14" />
        </Grid>

        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=BookType}" Value="Born">
                <Setter TargetName="BookTypeL" Property="Text" Value="B" />
                <Setter TargetName="BookTypeL" Property="Foreground" Value="White" />
                <Setter TargetName="BookCircle" Property="Fill" Value="{DynamicResource BookColor2}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="Dead">
                <Setter TargetName="BookTypeL" Property="Text" Value="D" />
                <Setter TargetName="BookTypeL" Property="Foreground" Value="White" />
                <Setter TargetName="BookCircle" Property="Fill" Value="{DynamicResource BookColor1}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="Marriages">
                <Setter TargetName="BookTypeL" Property="Text" Value="V" />
                <Setter TargetName="BookTypeL" Property="Foreground" Value="White" />
                <Setter TargetName="BookCircle" Property="Fill" Value="{DynamicResource BookColor3}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="HouseCall">
                <Setter TargetName="BookTypeL" Property="Text" Value="Ai" />
                <Setter TargetName="BookTypeL" Property="Foreground" Value="White" />
                <Setter TargetName="BookCircle" Property="Fill" Value="{DynamicResource BookColor4}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="MoveIn">
                <Setter TargetName="BookTypeL" Property="Text" Value="I" />
                <Setter TargetName="BookTypeL" Property="Foreground" Value="White" />
                <Setter TargetName="BookCircle" Property="Fill" Value="{DynamicResource BookColor5}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="MoveOut">
                <Setter TargetName="BookTypeL" Property="Text" Value="U" />
                <Setter TargetName="BookTypeL" Property="Foreground" Value="White" />
                <Setter TargetName="BookCircle" Property="Fill" Value="{DynamicResource BookColor6}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="Juridical">
                <Setter TargetName="BookTypeL" Property="Text" Value="B" />
                <Setter TargetName="BookTypeL" Property="Foreground" Value="White" />
                <Setter TargetName="BookCircle" Property="Fill" Value="Gray" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=BookType}" Value="BoU">
                <Setter TargetName="BookTypeL" Property="Text" Value="Bo" />
                <Setter TargetName="BookTypeL" Property="Foreground" Value="Black" />
                <Setter TargetName="BookCircle" Property="Fill" Value="DarkGray" />
            </DataTrigger>
        </DataTemplate.Triggers>

    </DataTemplate>

</ResourceDictionary>